package me.helllp.dake.core.utils;

import me.helllp.dake.core.base.BasePo;
import me.helllp.dake.core.bean.DakeAuthAccount;

public class PoUtil {
    /**
     * 对PO进行基本属性的设置
     *
     * @param po 修改此PO的属性
     */
    public static void setInsertPo(BasePo po) {
        DakeAuthAccount user = AccountUtil.toAuthAccount();
        setInsertPo(po, user.getUserAccount());
    }

    public static void setInsertPo(BasePo po, String userAccount) {
        long time = System.currentTimeMillis();
        po.setCreateTime(time);
        po.setModifyTime(time);
        po.setCreateUser(userAccount);
        po.setModifyUser(userAccount);
    }

    public static void setUpdatePo(BasePo po) {
        DakeAuthAccount user = AccountUtil.toAuthAccount();
        setUpdatePo(po, user.getUserAccount());
    }

    public static void setUpdatePo(BasePo po, String userAccount) {
        long time = System.currentTimeMillis();
        po.setModifyTime(time);
        po.setModifyUser(userAccount);
    }

}
